<?php

namespace Database\Seeders;

use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;

class FoodTakeawaySeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        // 生成50个食品
        \App\Models\Food::factory(50)->create();

        // 每个食品生成1-3个外卖套餐
        \App\Models\Food::each(function ($food) {
            \App\Models\Takeaway::factory(rand(1, 3))->create([
                'food_id' => $food->id
            ]);
        });
    }
}
